﻿<div class="tabbable">
<ul class="nav nav-tabs" id="myTab">
	<li class="active">
		<a data-toggle="tab" href="#tab1">
			用户组管理
		</a>
	</li>

	<li class="tab-red">
		<a data-toggle="tab" href="#tab2">
			添加用户组
		</a>
	</li>
</ul>
<div class="tab-content">

	<div id="tab1" class="tab-pane active">

				<div role="grid" id="editabledatatable_wrapper" class="dataTables_wrapper form-inline no-footer">
					<table class="table table-striped table-hover table-bordered dataTable no-footer" id="editabledatatable" aria-describedby="editabledatatable_info">
						<thead class="bordered-bottom-1 bordered-orange">
						<tr>
							<th class="text-center">ID</th>
							<th class="text-center">用户组名</th>
							<th class="text-center">备注</th>
							<th class="text-center">操作</th>
						</tr>
						</thead>
						<tbody>
						<?php
							foreach( $user_group as $v ):
						?>
						<tr>
							<td class="text-center"><?=$v->id;?></td>
							<td class="text-center"><?=$v->name;?></td>
							<td class="text-center"><?=$v->remark;?></td>
							<td class="text-center">
								<button class="btn btn-info btn-xs edit" onclick="show_modal( 'modal', '<?=site_url('user/edit_group/' . $v->id )?>' )"><i class="fa fa-pencil"></i>编辑</button>
								<button class="btn btn-danger btn-xs delete" onclick="bb_confirm( '确定要删除该用户组吗？', '<?=site_url( 'user/do_del_group/'. $v->id )?>' )"><i class="fa fa-trash-o"></i> 删除</button>
							</td>
						</tr>
						<?php
						endforeach;
						?>
						</tbody>
					</table>
				</div>
		<div class="clearfix"></div>
	</div>
	<div id="tab2" class="tab-pane">
		<form class="form">
			<div class="form-group clearfix form-bordered">
				<label class="control-label col-md-1">用户组名</label>

				<div class="col-md-11">
					<div class="form-group">
						<input type="text" class="form-control" name="name" id="name" placeholder="用户组名">
					</div>
				</div>
			</div>
			<div class="form-group clearfix form-bordered">
				<label class="control-label col-md-1">备注</label>

				<div class="col-md-11">
					<div class="form-group">
						<input type="text" class="form-control" name="remark" id="remark" placeholder="备注">
					</div>
				</div>
			</div>
			<div class="form-group clearfix form-bordered">
				<label class="control-label col-md-1">权限</label>

				<div class="col-md-11">
					<div class="form-group">
							<div class="checkbox">
									<label>
										<input type="checkbox" name="right[]" value="">
										<span class="text">权限名称</span>
									</label>
									<label>
										<input type="checkbox" name="right[]" value="">
										<span class="text">权限名称</span>
									</label>

							</div>
						</div>
				</div>
			</div>
			<div class="form-group text-right clearfix">
				<button class="btn btn-success" type="button" id="add_group">添加</button>
				<button class="btn btn-default" type="button" id="cancel">取消</button>
			</div>
		</form>
	</div>

</div>
</div>

<script>
	$("#add_group").click(function(){
		$.post(
			"<?=site_url( 'user/do_add_group' );?>",
			{
				name:$("#name").val(),
				remark:$("#remark").val(),
			},
			function( json ){
			    error_clear();
			    data = eval( '(' + json + ')' );
			    if( data.status == 'error' ){
				    error( 'warning', data.error );
			    }else{
				    error( 'success', data.error );
				    window.location.href = '<?=site_url( 'user/group')?>';
			    }
		    }
		)
	});
	$("#cancel").click(function(){
		window.location.reload();
	});
</script>

